package com.itcast.demoone.kotlin

fun main() {
    println(ifFun(10, 20))
    println(whenFun(3))
    println(whenFun2(90))
    println(whenFun3(80))
}

// 1. if语句
fun ifFun(num1: Int, num2: Int):  Int{
   /* if (num1 > num2) {
        return num1
    } else {
        return num2
    }*/

    /*return if (num1 > num2) {
        num1
    } else {
        num2
    }*/

    return if (num1 > num2) num1 else num2
}

// 2. when语句
fun whenFun(num: Int): String {
    return when (num) {
        1 -> "one"
        2 -> "two"
        3 -> "three"
        else -> "other"
    }
}

fun whenFun2(score: Int): String {
    return when {
        score >= 90 -> "优秀"
        score >= 80 -> "良好"
        score >= 70 -> "及格"
        else -> "不及格"
    }
}

fun whenFun3(score: Int): String = when(score) {
    in 90..100 -> "优秀"
    in 80..89 -> "良好"
    in 70..79 -> "及格"
    else -> "不及格"
}